package com.cli.springboottemplateengine.engine;

import org.springframework.util.StopWatch;

import java.util.Map;
import java.util.UUID;

public interface TemplateEngine {
    int time = 1;

    default String render(String templateContent, Map<String, Object> model) {
        StopWatch sw = new StopWatch(getType() + " 渲染-"+ time +"次-时间");
        String result = null;
        sw.start();
        for (int i = 0; i < time; i++) {
            result = doRender(templateContent + UUID.randomUUID(), model);
        }
        sw.stop();
        System.out.println("sw.prettyPrint()输出：");
        System.out.println(sw.prettyPrint());
        return result;
    }

    /**
     * 渲染模板
     */
    String doRender(String templateContent, Map<String, Object> model);

    /**
     * 返回当前引擎类型标识
     */
    String getType();
}

